//---------------------------------------------------------------------------

#ifndef InvoiceDlgH
#define InvoiceDlgH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <ExtCtrls.hpp>

#include "DateUtilities.h"
#include "InvoiceBridge.h"
#include "CustomerBridge.h"
#include "Error.h"
#include "PaymentTypeBridge.h"
#include <ComCtrls.hpp>

//---------------------------------------------------------------------------
class TfrmInvoiceDlg : public TForm
{
__published:	// IDE-managed Components
        TPanel *pnlMain;
        TLabel *lblInvoice;
        TLabel *lblDate;
        TEdit *edtInvoice;
        TBitBtn *btnOk;
        TBitBtn *btnHelp;
        TBitBtn *btnCancel;
        TLabel *lblPage;
        TEdit *edtPage;
        TLabel *lblAmount;
        TEdit *edtAmount;
        TSpeedButton *btnDate;
        TEdit *edtDate;
        TLabel *lblCurrency;
        TLabel *lblPaymentType;
        TComboBox *cmbPaymentTypes;
        void __fastcall btnOKClick(TObject *Sender);
        void __fastcall btnDateClick(TObject *Sender);
        void __fastcall FormDestroy(TObject *Sender);
        void __fastcall edtInvoiceEnter(TObject *Sender);
private:
        TInvoiceBridge* bridge;
        TPaymentTypeBridge* ptBridge;
        TInvoice* original;
        TInvoice* invoice;

        void FillPaymentTypesCombo();
        void ShowInvoice();
        void GatherInvoice();
        void AddNewInvoice();
        void UpdateInvoice();

        void ValidateData();
        void HandleError( TError * e);
        static bool IsActionAllowed( TInvoiceBridge * bridge, TInvoice * original, TInvoice * invoice);
public:
        __fastcall TfrmInvoiceDlg(TComponent* Owner, TDatabase* dbMain, TInvoiceBridge* bridge, TInvoice* invoice);
        static bool IsGapExist( TInvoiceBridge * bridge, TInvoice * original, TInvoice * invoice);
};
//---------------------------------------------------------------------------
#endif
